<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="外协单一览表" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<link href="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="/css/BillList.css" />
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script src="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.js"></script>
<script language="javascript">
	function doShow(id,examined){
		var editType="";
		if(examined=='Y'){
			<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';COOP_MODI;')!=-1}">editType="MODIFY";</c:if>
		}
		var url="/cooper/CooperBillEdit.ihtm?id="+id+"&edit_type="+editType;
		ShowIframe("外协单",url,1024,500,"refreshWin()");
	}
	function refreshWin(){
		if(popRetVal!=null){
			window.location="/cooper/CooperBillSearchResult.ihtm?"+getSearchCondition()+"&current_page=${qr.pageIndex}";
		}
	}
	function doPrint(id){
		showWin(900,600,"/cooper/CooperBillPrint.ihtm?id="+id);
	}
	function checkDateStr(){
		var startDate=document.getElementById("start_date").value;
		if(startDate==null || startDate==''){
			ShowAlert('提示框','请选择开始日期',200,100);
			return false;
		}else{
			var arr=startDate.split("-");
			if(arr.length==null || arr.length!=3){
				ShowAlert('提示框','开始日期格式不正确',200,100);
				return false;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','开始日期格式不正确',200,100);
				return false;
			}
		}
		var endDate=document.getElementById("end_date").value;
		if(endDate==null || endDate==''){
			ShowAlert('提示框','请选择结束日期',200,100);
			return false;
		}else{
			var arr=endDate.split("-");
			if(arr.length==null || arr.length!=3){
				ShowAlert('提示框','结束日期格式不正确',200,100);
				return false;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','结束日期格式不正确',200,100);
				return false;
			}
		}
		return true;
	}
	function createPageParaStr(){
		var str="start_date="+encodeURIComponent(document.getElementById("start_date").value);
		str=str+"&end_date="+encodeURIComponent(document.getElementById("end_date").value);
		
		var examined="A";
		if(document.getElementById("examine1").checked){
			examined="Y";
		}else if(document.getElementById("examine2").checked){
			examined="N";
		}
		str=str+"&examined="+examined;
		
		var gathered="A";
		if(document.getElementById("gather1").checked){
			gathered="Y";
		}else if(document.getElementById("gather2").checked){
			gathered="P";
		}else if(document.getElementById("gather3").checked){
			gathered="N";
		}
		str=str+"&gathered="+gathered;
		
		var paied="A";
		if(document.getElementById("paied1").checked){
			paied="Y";
		}else if(document.getElementById("paied2").checked){
			paied="N";
		}
		str=str+"&paied="+paied;
		
		str=str+"&manager_name="+encodeURIComponent(document.getElementById("manager_name").value);
		str=str+"&creater_name="+encodeURIComponent(document.getElementById("creater_name").value);
		str=str+"&est_name="+encodeURIComponent(document.getElementById("est_name").value);
		str=str+"&bill_code="+encodeURIComponent(document.getElementById("bill_code").value);
		str=str+"&min_cost="+encodeURIComponent(document.getElementById("min_cost").value.trim());
		str=str+"&max_cost="+encodeURIComponent(document.getElementById("max_cost").value.trim());
		str=str+"&content="+encodeURIComponent(document.getElementById("content").value);
		str=str+"&ts_id="+document.getElementById("ts_id").value;
		str=str+"&order_by="+document.getElementById("order_by").value;
		str=str+"&order_sc="+document.getElementById("order_sc").value;
		
		return str;
	}
	
	function createProgramParaStr(){
		var str="start_date="+encodeURIComponent(document.getElementById("hid_start_date").value);
		str=str+"&end_date="+encodeURIComponent(document.getElementById("hid_end_date").value);
		str=str+"&examined=${examined}";
		str=str+"&gathered=${gathered}";
		str=str+"&paied=${paied}";
		str=str+"&manager_name="+encodeURIComponent(document.getElementById("hid_manager_name").value);
		str=str+"&creater_name="+encodeURIComponent(document.getElementById("hid_creater_name").value);
		str=str+"&est_name="+encodeURIComponent(document.getElementById("hid_est_name").value);
		str=str+"&bill_code="+encodeURIComponent(document.getElementById("hid_bill_code").value);
		str=str+"&min_cost="+encodeURIComponent(document.getElementById("hid_min_cost").value);
		str=str+"&max_cost="+encodeURIComponent(document.getElementById("hid_max_cost").value);
		str=str+"&content="+encodeURIComponent(document.getElementById("hid_content").value);
		str=str+"&ts_id=${tsId}";
		str=str+"&order_by=${orderBy}";
		str=str+"&order_sc=${orderSc}";
		
		return str;
	}
	function doSearch(){
		var str;
		if(IsAdvSearch){//高级
			str="search_type=1";
			if(document.getElementById("cb_cooper_date").checked){
				if(checkDateStr()){
					str=str+"&cb_cooper_date=1";
				}else{
					return;
				}
			}
			if(document.getElementById("cb_examine").checked){
				str=str+"&cb_examine=1";
			}
			
			if(document.getElementById("cb_gather").checked){
				str=str+"&cb_gather=1";
			}
			
			if(document.getElementById("cb_pay").checked){
				str=str+"&cb_pay=1";
			}
			
			if(document.getElementById("cb_manager").checked){
				var managerName=document.getElementById("manager_name").value.trim();
				if(managerName==null || managerName==""){
					ShowAlert('提示框','请输入业务员姓名',200,100);
					return;
				}
				str=str+"&cb_manager=1";
			}
			if(document.getElementById("cb_creater").checked){
				var createrName=document.getElementById("creater_name").value.trim();
				if(createrName==null || createrName==""){
					ShowAlert('提示框','请输入开单人姓名',200,100);
					return;
				}
				str=str+"&cb_creater=1";
			}
			if(document.getElementById("cb_est").checked){
				var estName=document.getElementById("est_name").value.trim();
				if(estName==null || estName==""){
					ShowAlert('提示框','请输入外协单位',200,100);
					return;
				}
				str=str+"&cb_est=1";
			}
			if(document.getElementById("cb_bill_code").checked){
				var billCode=document.getElementById("bill_code").value.trim();
				if(billCode==null || billCode==""){
					ShowAlert('提示框','请输入外协单号',200,100);
					return;
				}
				str=str+"&cb_bill_code=1";
			}
			if(document.getElementById("cb_cost").checked){
				var minCost=document.getElementById("min_cost").value.trim();
				if(minCost==null || minCost==""){
					ShowAlert('提示框','请输入最小金额',200,100);
					return;
				}else if(isNaN(minCost)){
					ShowAlert('提示框','最小金额只能是数字',200,100);
					return;
				}
				var maxCost=document.getElementById("max_cost").value.trim();
				if(maxCost==null || maxCost==""){
					ShowAlert('提示框','请输入最大金额',200,100);
					return;
				}else if(isNaN(maxCost)){
					ShowAlert('提示框','最大金额只能是数字',200,100);
					return;
				}
				str=str+"&cb_cost=1";
			}
			if(document.getElementById("cb_content").checked){
				var content=document.getElementById("content").value.trim();
				if(content==null || content==""){
					ShowAlert('提示框','请输入摘要',200,100);
					return;
				}
				str=str+"&cb_content=1";
			}
			if(document.getElementById("cb_ts").checked){
				var tsId=document.getElementById("ts_id").value;
				if(tsId==null || tsId=="" || tsId=="0"){
					ShowAlert('提示框','请选择帐套',200,100);
					return;
				}
				str=str+"&cb_ts=1";
			}
			if(document.getElementById("cb_order").checked){
				var orderBy=document.getElementById("order_by").value;
				if(orderBy==null || orderBy==""){
					ShowAlert('提示框','请选择排序类型',200,100);
					return;
				}
				str=str+"&cb_order=1";
			}
		}else{//快速
			str="search_type=2";
			if(!checkDateStr()){
				return;
			}
		}
		var paraStr=createPageParaStr();
		if(paraStr!=""){
			str=str+"&"+paraStr;
		}
		window.location="/cooper/CooperBillSearchResult.ihtm?"+str;
	}
	function doGo(pageIndex){
		var str=getSearchCondition();
		str=str+"&current_page="+pageIndex;
		window.location="/cooper/CooperBillSearchResult.ihtm?"+str;
	}
	
	function getSearchCondition(){
		var searchType="${searchType}";
		var str="search_type="+searchType;
		if(searchType=="1"){//高级
			<c:if test="${cbCooperDate=='1'}">str=str+"&cb_cooper_date=1";</c:if>
			<c:if test="${cbExamine=='1'}">str=str+"&cb_examine=1";</c:if>
			<c:if test="${cbGather=='1'}">str=str+"&cb_gather=1";</c:if>
			<c:if test="${cbPay=='1'}">str=str+"&cb_pay=1";</c:if>
			<c:if test="${cbManager=='1'}">str=str+"&cb_manager=1";</c:if>
			<c:if test="${cbCreater=='1'}">str=str+"&cb_creater=1";</c:if>
			<c:if test="${cbEst=='1'}">str=str+"&cb_est=1";</c:if>
			<c:if test="${cbCost=='1'}">str=str+"&cb_cost=1";</c:if>
			<c:if test="${cbBillCode=='1'}">str=str+"&cb_bill_code=1";</c:if>
			<c:if test="${cbContent=='1'}">str=str+"&cb_content=1";</c:if>
			<c:if test="${cbTs=='1'}">str=str+"&cb_ts=1";</c:if>
			<c:if test="${cbOrder=='1'}">str=str+"&cb_order=1";</c:if>
		}else{//快速
			
		}
		var paraStr=createProgramParaStr();
		if(paraStr!=""){
			str=str+"&"+paraStr;
		}
		return str;
	}
	function doJump(pageIndex){
		if(window.event.keyCode==13){
			doGo(pageIndex);
		}
	}
	function DoubleClick(it){
		var ob_arr = document.getElementsByName("query_checkbox");
		var id="";
		var examined="";
		if(ob_arr.length>=it.getAttribute("index")){
			id=ob_arr[it.getAttribute("index")-1].value;
			examined=ob_arr[it.getAttribute("index")-1].getAttribute("examined");
		}
		if(id==""){
			return;
		}
		doShow(id,examined);
	}
	
	function doCancel(){
		window.close();
	}
	function doInit(){
		Window_Onload();
		if(window.screen.availWidth>1280){
			var w=window.screen.availWidth*0.98;
			window.resizeTo(w,600);
			//居中
			var resizeWinTop=(window.screen.availHeight-600)/2;
			var resizeWinLeft=(window.screen.availWidth-w)/2;
			window.moveTo(resizeWinLeft,resizeWinTop);
		}
	}
	function checkInput(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
	function doAutoCheck(objId){
		document.getElementById(objId).checked=true;
	}
	function selectStafferName(objId,checkObjId){
		var url="/base/StafferMainForSelect.ihtm";
		var cb="selectStafferNameCallBack('"+objId+"','"+checkObjId+"')";
		ShowIframe("选择员工",url,800,500,cb);
	}
	function selectStafferNameCallBack(objId,checkObjId){
		if(popRetVal!=null){
			var arr=popRetVal.split(";");
			document.getElementById(objId).value=arr[1];
			doAutoCheck(checkObjId);
		}
	}
	function doDownload(){
		var str=getSearchCondition();
		window.location="/cooper/CooperBillSearchResult.ihtm?content_type=EXCEL&"+str;
	}
	function showExaPage(id){
		var url="/cooper/CooperBillInfoForExamine.ihtm?id="+id;
		ShowIframe("外协单审核",url,900,500,"refreshWin()");
	}
	function showUnExaPage(id){
		var url="/cooper/CooperBillInfoForUnExamine.ihtm?id="+id;
		ShowIframe("外协单反审核",url,900,500,"refreshWin()");
	}
	function showGatPage(id){
		var url="/cooper/GatherBillNew.ihtm?cooper_bill_id="+id;
		ShowIframe("外协单收货",url,1024,500,"refreshWin()");
	}
	function showGatSearchPage(bbCode){
		showWin(900,600,'/cooper/GatherBillSearchResult.ihtm?search_type=1&cb_cb_code=1&cb_code='+encodeURIComponent(bbCode));
	}
	function showPayPage(id){
		var url="/finance/PayBillNew.ihtm?data_type=COOPER&bill_id_str="+id;
		ShowIframe("外协单付款",url,1024,500,"refreshPrintWin('PAY')");
	}
	function refreshPrintWin(type){
		if(popRetVal!=null){
			var url="/cooper/CooperBillSearchResult.ihtm?"+getSearchCondition()+"&current_page=${qr.pageIndex}";
			if(popRetVal.indexOf(";")!=-1){
				var arr=popRetVal.split(";");
				if(arr[1]!=null && arr[1]=="Y"){
					url=url+"&print_id="+arr[0]+"&print_bill="+type;
					if(arr[2]!=null){
						url=url+"&print_detail="+arr[2];
					}
				}
			}
			window.location=url;
		}
	}
	function showAdjPage(id){
		var url="/finance/AdjustTypeSelect.ihtm?bill_type=COOPER_BILL";
		ShowIframeNoScroll("选择调帐类型",url,240,230,"doAdjNew("+id+")");
	}
	function doAdjNew(id){
		if(popRetVal!=null){
			var url="/finance/AdjustBillNew.ihtm?data_type=BILL&adjust_type="+popRetVal+"&bill_id_str="+id;
			ShowIframe("调帐单",url,1024,500,"refreshPrintWin('ADJ')");
		}
	}
	function doPrintCallBack(){
		var printId="${printId}";
		var printBill="${printBill}";
		var printDetail="${printDetail}";
		if(printId!=null && printId!=""){
			if(printBill=="PAY"){
				showWin(900,600,"/finance/PayBillPrint.ihtm?id="+printId+"&print_detail="+printDetail);
			}else if(printBill=="ADJ"){
				showWin(900,600,"/finance/AdjustBillPrint.ihtm?id="+printId);
			}
		}
	}
	function setDate(type){
		var d=new Date();
		var startStr="";
		var endStr="";
		if(type=="CURRENT_MONTH"){
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-01";
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="PREVIEW_MONTH"){
			d=new Date(d.getFullYear(),d.getMonth(),1);
			d.setDate(d.getDate()-1);
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-1";
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="TODAY"){
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="YESTERDAY"){
			d.setDate(d.getDate()-1);
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}
		document.getElementById("start_date").value=startStr;
		document.getElementById("end_date").value=endStr;
		doAutoCheck("cb_cooper_date");
	}
	function showList(type){
		var str="search_type=1&cb_ts=1&ts_id=DF_TS_ID";
		if(type=='CAN_EXAM'){
			str=str+"&cb_examine=1&examined=N";
		}else if(type=='CAN_GATH'){
			str=str+"&cb_examine=1&examined=Y&cb_gather=1&gathered=N";
		}else if(type=='UN_PAY'){
			str=str+"&cb_examine=1&examined=Y&cb_pay=1&paied=N";
		}else if(type=='ZERO_COST'){
			str=str+"&cb_cost=1&min_cost=0&max_cost=0";
		}else{
			return;
		}
		window.location="/cooper/CooperBillSearchResult.ihtm?"+str;
	}
	function showRelBill(id,code){
		showWin(900,600,"/cooper/CooperRelBillList.ihtm?id="+id+"&code="+code);
	}
	function selectEstName(){
		var url="/base/EstablishmentListForSelect.ihtm?type=COOPERATOR";
		ShowIframe("选择外协商",url,900,500,"selectEstNameCallBack()");
	}
	function selectEstNameCallBack(){
		if(popRetVal!=null){
			document.getElementById("est_name").value=popRetVal[1];
			doAutoCheck("cb_est");
		}
	}
</script>
</head>
<c:set var="canExa" value="N" />
<c:set var="canUnExa" value="N" />
<c:set var="canGat" value="N" />
<c:set var="canGatSearch" value="N" />
<c:set var="canPay" value="N" />
<c:set var="canAdj" value="N" />
<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';COOP_EXAM;')!=-1}"><c:set var="canExa" value="Y" /></c:if>
<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';COOP_UN_EXAM;')!=-1}"><c:set var="canUnExa" value="Y" /></c:if>
<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';GATH_BILL;')!=-1}"><c:set var="canGat" value="Y" /></c:if>
<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';GATH_BILL_SEAR;')!=-1}"><c:set var="canGatSearch" value="Y" /></c:if>
<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';PAY_BILL;')!=-1}"><c:set var="canPay" value="Y" /></c:if>
<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';ADJU_BILL;')!=-1}"><c:set var="canAdj" value="Y" /></c:if>

<body oncontextmenu="return false">
<div class="Wrap"><!-- 页面主框架 -->
    
	<div id="ListContainer" class="Container"><!-- 主体容器 -->
	    
	    <!-- 标题栏 -->
	    <div class="Heading BillIcon">
	        <div class="HeadingContent">
	            <h1>外协单一览表</h1>
	            <span class="Note">通过外协单查询，可以根据外协单状态进行编辑、打印、收货、付款、调账等操作。<span style="color:black">黑色</span>表示未审核、<span style="color:blue">蓝色</span>表示已审核、<span style="color:red">红色</span>表示已收完、<span style="color:green">绿色</span>表示已付清。</span>
	        </div>
	    </div>
	
		<!-- 主内容 -->
		<div class="Content">
	        <!-- 筛选控件栏 -->
	        <div class="FilterBar ClearFix">
	            <div class="SearchIcon"></div>
	            <span class="fl">
	            	<table class="MoreOption" cellpadding="0" cellspacing="0">
	            		<th class="c1" width="80px">
	            			<input type="checkbox" name="cb_cooper_date" id="cb_cooper_date" <c:if test="${cbCooperDate=='1' || searchType=='2'}">checked="true"</c:if> style="visibility:hidden;" />
	            			外协日期
	            		</th>
	            		<td width="360px">
	            			<input type="text" class="TextBox Datetime" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_cooper_date');" id="start_date" name="start_date" value="<c:out value="${startDate}" />">
			            	<img src="/images/calendar.gif" class="imgIconButton" onClick="displayCalendar(document.getElementById('start_date'),'yyyy-mm-dd',this,false,'doAutoCheck(\'cb_cooper_date\')');">
			            	<input type="hidden" id="hid_start_date" value="<c:out value="${startDate}" />">
			            	至
			            	<input type="text" class="TextBox Datetime" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_cooper_date');" id="end_date" name="end_date" value="<c:out value="${endDate}" />">
			            	<img src="/images/calendar.gif" class="imgIconButton" onClick="displayCalendar(document.getElementById('end_date'),'yyyy-mm-dd',this,false,'doAutoCheck(\'cb_cooper_date\')');">
			            	<input type="hidden" id="hid_end_date" value="<c:out value="${endDate}" />">
			            	<a href="javascript:setDate('CURRENT_MONTH');">本月</a>
							<a href="javascript:setDate('TODAY');">今天</a>
							<a href="javascript:setDate('YESTERDAY');">昨天</a>
							<a href="javascript:setDate('PREVIEW_MONTH');">上月</a>
	            		</td>
	            	</table>
	            </span>
	            <span class="fr">
	            	<a href="javascript:;" id="lnkMoreOption">更多查询选项</a>
		  			<input type="button" value=" 查 询" onClick="doSearch();" class="buttom search-but" id="sSearchButton" name="sSearchButton">
	                <input type="button" value=" 导 出" onClick="doDownload();" class="buttom search-out" id="sDownloadButton" name="sDownloadButton" <c:if test="${currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';NO_EXPO;')!=-1}">disabled="true"</c:if>>
	            </span>
				<div id="dvMoreOptionBox" class="MoreOptionBox" style="display:none;">
					<table class="MoreOption" cellpadding="0" cellspacing="0">
						<tr>
							<th class="c1" width="80px">
			        			<input type="checkbox" name="cb_bill_code" id="cb_bill_code" <c:if test="${cbBillCode=='1'}">checked="true"</c:if>>
			        			外协单号
			        		</th>
			        		<td class="c1" width="260px">
			        			<input type="text" class="TextBox" maxlength="50" name="bill_code" id="bill_code" onFocus="doAutoCheck('cb_bill_code');" onKeyUp="checkInput();" value="<c:out value="${billCode}" />">
								<input type="hidden" id="hid_bill_code" value="<c:out value="${billCode}" />">
			    			</td>
			    			<th class="c2" width="80px">
	                        	<input type="checkbox" name="cb_examine" id="cb_examine" <c:if test="${cbExamine=='1'}">checked="true"</c:if>>
	                        	审核状态
	                        </th>
	                    	<td class="c2" width="280px">
	                        	<input type="radio" name="examined" id="examine1" onClick="doAutoCheck('cb_examine');" <c:if test="${examined==null || examined=='' || examined=='Y'}">checked="true"</c:if>>已审核
	                        	<input type="radio" name="examined" id="examine2" onClick="doAutoCheck('cb_examine');" <c:if test="${examined=='N'}">checked="true"</c:if>>未审核
	                        	<input type="radio" name="examined" id="examine3" onClick="doAutoCheck('cb_examine');" <c:if test="${examined=='A'}">checked="true"</c:if>>全部
	                    	</td>
			    		</tr>
						<tr>
			    			<th class="c1">
			        			<input type="checkbox" name="cb_est" id="cb_est" <c:if test="${cbEst=='1'}">checked="true"</c:if>>
			        			外协单位
			        		</th>
			    			<td class="c1">
			        			<input type="text" class="TextBox" maxlength="50" name="est_name" id="est_name" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_est');" value="<c:out value="${estName}" />">
								<img class="imgIconButton" src="/images/make-a.gif" onClick="selectEstName();" />
								<input type="hidden" id="hid_est_name" value="<c:out value="${estName}" />">
			    			</td>
	                    	<th class="c2">
	                        	<input type="checkbox" name="cb_gather" id="cb_gather" <c:if test="${cbGather=='1'}">checked="true"</c:if>>
	                        	收货状态
	                        </th>
	                    	<td class="c2">
	                        	<input type="radio" name="gather" id="gather1" onClick="doAutoCheck('cb_gather');" <c:if test="${gathered==null || gathered=='' || gathered=='Y'}">checked="true"</c:if>>已收完
								<input type="radio" name="gather" id="gather2" onClick="doAutoCheck('cb_gather');" <c:if test="${gathered=='P'}">checked="true"</c:if>>未收完
								<input type="radio" name="gather" id="gather3" onClick="doAutoCheck('cb_gather');" <c:if test="${gathered=='N'}">checked="true"</c:if>>未收货
								<input type="radio" name="gather" id="gather4" onClick="doAutoCheck('cb_gather');" <c:if test="${gathered=='A'}">checked="true"</c:if>>全部
	                    	</td>
	                	</tr>
						<tr>
			    			<th class="c1">
			        			<input type="checkbox" name="cb_content" id="cb_content" <c:if test="${cbContent=='1'}">checked="true"</c:if>>
			        			摘要
			        		</th>
			    			<td class="c1">
			        			<input type="text" class="TextBox" maxlength="50" name="content" id="content" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_content');" value="${content}" >
								<input type="hidden" id="hid_content" value="<c:out value="${content}" />">
			    			</td>
	                    	<th class="c2">
	                        	<input type="checkbox" name="cb_pay" id="cb_pay" <c:if test="${cbPay=='1'}">checked="true"</c:if>>
	                        	付款状态
	                        </th>
	                    	<td class="c2">
	                        	<input type="radio" name="paied" id="paied1" onClick="doAutoCheck('cb_pay');" <c:if test="${paied=='Y'}">checked="true"</c:if>>已付完
								<input type="radio" name="paied" id="paied2" onClick="doAutoCheck('cb_pay');" <c:if test="${paied=='N'}">checked="true"</c:if>>未付完
								<input type="radio" name="paied" id="paied3" onClick="doAutoCheck('cb_pay');" <c:if test="${paied==null || paied=='' || paied=='A'}">checked="true"</c:if>>全部
	                    	</td>
	                	</tr>
						<tr>
			    			<th class="c1">
			        			<input type="checkbox" name="cb_cost" id="cb_cost" <c:if test="${cbCost=='1'}">checked="true"</c:if>>
			        			金额
			        		</th>
			    			<td>
			        			<input type="text" class="TextBox Money" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_cost');" id="min_cost" name="min_cost" value="${minCost}">
								至
								<input type="text" class="TextBox Money" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_cost');" id="max_cost" name="max_cost" value="${maxCost}">
								<input type="hidden" id="hid_min_cost" value="<c:out value="${minCost}" />">
								<input type="hidden" id="hid_max_cost" value="<c:out value="${maxCost}" />">
			    			</td>
	                    	<th class="c2">
			        			<input type="checkbox" name="cb_manager" id="cb_manager" <c:if test="${cbManager=='1'}">checked="true"</c:if>>
			        			业务员
			        		</th>
			    			<td class="c3">
			    				<input type="text" class="TextBox" maxlength="15" name="manager_name" id="manager_name" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_manager');" value="<c:out value="${managerName}" />" >
								<img class="imgIconButton" src="/images/make-a.gif" onClick="selectStafferName('manager_name','cb_manager');" />
			        			<input type="hidden" id="hid_manager_name" value="<c:out value="${managerName}" />">
			    			</td>
	                	</tr>
						<tr>
			    			<th class="c1">
			        			<input type="checkbox" name="cb_ts" id="cb_ts" <c:if test="${cbTs=='1'}">checked="true"</c:if>>
	                        	账套
			        		</th>
			    			<td class="c1">
			        			<select name="ts_id" id="ts_id" onFocus="doAutoCheck('cb_ts');">
				    				<option value="0">==请选择账套==</option>
				    				<c:forEach var="item" items="${tsList}">
									<option value="${item.id}" <c:if test="${tsId==item.id}">selected</c:if>>${item.title}</option></c:forEach>
								</select>
			        		</td>
			        		<th class="c2">
			        			<input type="checkbox" name="cb_creater" id="cb_creater" <c:if test="${cbCreater=='1'}">checked="true"</c:if>>
			        			开单人
			        		</th>
			    			<td class="c3">
			        			<input type="text" class="TextBox" maxlength="15" name="creater_name" id="creater_name" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_creater');" value="<c:out value="${createrName}" />">
								<img class="imgIconButton" src="/images/make-a.gif" onClick="selectStafferName('creater_name','cb_creater');" />
								<input type="hidden" id="hid_creater_name" value="<c:out value="${createrName}" />">
			    			</td>
	                	</tr>
					</table>
				
					<div class="OptionOrderBy">
	                	<input type="checkbox" name="cb_order" id="cb_order" <c:if test="${cbOrder=='1'}">checked="true"</c:if>>
	                    	排序类型
	                    <select name="order_by" id="order_by" onFocus="doAutoCheck('cb_order');">
	                        <option value="">==请选择==</option>
					  		<option value="COOPER_DATE" <c:if test="${orderBy=='COOPER_DATE'}">selected</c:if>>外协日期</option>
					  		<option value="COST" <c:if test="${orderBy=='COST'}">selected</c:if>>金额</option>
					  		<option value="BILL_CODE" <c:if test="${orderBy=='BILL_CODE'}">selected</c:if>>单号</option>
					  		<option value="CONTENT" <c:if test="${orderBy=='CONTENT'}">selected</c:if>>摘要</option>
					  		<option value="EST_NAME" <c:if test="${orderBy=='EST_NAME'}">selected</c:if>>外协单位</option>
	                    </select>
	                    <select name="order_sc" id="order_sc" onFocus="doAutoCheck('cb_order');">
	                        <option value="ASC" <c:if test="${orderSc=='ASC'}">selected</c:if>>升序</option>
	                        <option value="DESC" <c:if test="${orderSc=='DESC'}">selected</c:if>>降序</option>
	                    </select>
	                    <span class="fr"><a href="javascript:;" id="lnkHiddenOption">隐藏查询选项</a></span>
	                </div>
				</div>
			</div>
			
			<!-- 提示信息显示栏 -->
	        <div class="MsgBar">
	            <%@include file="../inc/AlertMsg.jsp"%>
	        </div>

			<!-- 上栏 分页、操作等 -->
	        <div class="TopToolBar">
	            <table class="ListNoteInfo" cellpadding="0" cellspacing="0">
	            	<tr>
	                	<td>
	                		选择：
	                		<a href="javascript:showList('CAN_EXAM');">待审核</a>
						  	<a href="javascript:showList('CAN_GATH');">待收货</a>
						  	<a href="javascript:showList('UN_PAY');">未付款</a>
						  	<a href="javascript:showList('ZERO_COST');">零单价</a>
							<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';NO_TOTA;')==-1}">
	            				<br>
	            				<span>外协金额：${costTotal}元（已优惠：${favTotal}元） 调账：${adjustTotal}元</span>
								<span>已付：${payTotal}元（其中预付款：${imprestTotal}元） 欠款：${costTotal+adjustTotal-payTotal}元</span>
		            			<span>面积合计：${squareTotal}平方米</span>
								<span>长度合计：${lengMTotal}米&nbsp;${lengCmTotal}公分</span>
								<span>合同单数：${qr.totalCount}笔</span>
							</c:if>
	                	</td>
	            	</tr>
	            </table>
			</div>

      		<div class="table-list">
        		<table width="100%">
		          	<tr>
					  	<th width="10%">单号</td>
						<th width="7%">外协日期</td>
						<th width="12%">外协单位</td>
						<th width="14%">摘要</td>
						<th width="7%">交货日期</td>
						<th width="6%">金额</td>
						<th width="6%">调账</td>
						<th width="6%">已付</td>
						<th width="6%">欠款</td>
						<th width="5%">业务员</td>
						<th width="5%">开单人</td>
						<th width="8%">状态</td>
						<th width="8%">操作</td>
		          	</tr>
					<c:forEach var="item" items="${qr.list}" varStatus="i">
					<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
					<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
					<c:set var="defaultFontColor" value="#000000" />
					<c:if test="${item[1].examined=='Y'}"><c:set var="defaultFontColor" value="#0000cc" /></c:if>
					<c:if test="${item[1].gathered=='Y'}"><c:set var="defaultFontColor" value="#ff0000" /></c:if>
					<c:if test="${item[1].paied=='Y' && (item[0].imprest!=0.00 || item[1].paiedCost!=0.00 || item[1].adjustCost!=0.00)}">
						<c:set var="defaultFontColor" value="#009900" />
					</c:if>
					<tr class="${trClass}" style="cursor:pointer;color:${defaultFontColor}" defaultFontColor="${defaultFontColor}" index="${i.index+1}" ondblclick='javascript:DoubleClick(this)' onClick='javascript:ClickCheck(this)' onmouseout='javascript:mouseout(this)' onmouseover='javascript:mouseover(this)'>
						<td>
							<input type="radio" name='query_checkbox' value="${item[0].id}" examined="${item[1].examined}" style="display:none">
							${item[0].billCode}
						</td>
						<td><fmt:formatDate value="${item[0].cooperDate}" pattern="yyyy-MM-dd HH:mm"/></td>
						<td>${item[2]}<c:if test="${item[0].linkman!=null && item[0].linkman!=''}">(${item[0].linkman})</c:if></td>
						<td>${item[0].content}</td>
						<td>
							<c:if test="${item[0].gatherDate!=null}">
							<fmt:formatDate value="${item[0].gatherDate}" pattern="yyyy-MM-dd HH:mm"/>
							</c:if>
						</td>
						<td align="right">${item[0].cost}</td>
						<td align="right">${item[1].adjustCost}</td>
						<td align="right">${item[1].paiedCost}</td>
						<td align="right">${item[0].cost+item[1].adjustCost-item[1].paiedCost}</td>
						<td>${item[0].managerName}</td>
						<td>${item[0].createrName}</td>
						<td>
							<c:if test="${item[1].examined=='Y'}"><c:if test="${canUnExa=='Y'}"><a href="javascript:showUnExaPage('${item[0].id}');"></c:if>已审核<c:if test="${canUnExa=='Y'}"></a></c:if></c:if>
							<c:if test="${item[1].examined=='N'}"><c:if test="${canExa=='Y'}"><a href="javascript:showExaPage('${item[0].id}');"></c:if>未审核<c:if test="${canExa=='Y'}"></a></c:if></c:if>
							<br>
							<c:if test="${item[1].gathered=='N'}"><c:if test="${item[1].examined=='Y' && canGat=='Y'}"><a href="javascript:showGatPage('${item[0].id}');"></c:if>未收货<c:if test="${item[1].examined=='Y' && canGat=='Y'}"></a></c:if></c:if>
							<c:if test="${item[1].gathered=='P'}"><c:if test="${item[1].examined=='Y' && canGat=='Y'}"><a href="javascript:showGatPage('${item[0].id}');"></c:if>未收完<c:if test="${item[1].examined=='Y' && canGat=='Y'}"></a></c:if></c:if>
							<c:if test="${item[1].gathered=='Y'}"><c:if test="${canGatSearch=='Y'}"><a href="javascript:showGatSearchPage('${item[0].billCode}');"></c:if>已收完<c:if test="${canGatSearch=='Y'}"></a></c:if></c:if>
							
							<c:if test="${item[1].paied=='Y'}">
								<c:if test="${item[0].imprest!=0.00 || item[1].paiedCost!=0.00 || item[1].adjustCost!=0.00}">已付清</c:if>
								<c:if test="${!(item[0].imprest!=0.00 || item[1].paiedCost!=0.00 || item[1].adjustCost!=0.00)}">
									<c:if test="${item[1].gathered=='Y'}">已付清</c:if>
									<c:if test="${item[1].gathered!='Y'}">未付清</c:if>
								</c:if>
							</c:if>
							<c:if test="${item[1].paied!='Y'}"><c:if test="${item[1].examined=='Y' && canPay=='Y'}"><a href="javascript:showPayPage('${item[0].id}');"></c:if>未付清<c:if test="${item[1].examined=='Y' && canPay=='Y'}"></a></c:if></c:if>
						</td>
						<td>
							<a href="javascript:doShow('${item[0].id}','${item[1].examined}');">修改</a>
							<a href="javascript:doPrint('${item[0].id}');">打印</a>
							<c:if test="${item[1].paied!='Y' && item[1].examined=='Y' && canPay=='Y'}"><a href="javascript:showPayPage('${item[0].id}');">付款</a></c:if>
							<br>
							<c:if test="${canAdj=='Y' && item[1].examined=='Y'}"><a href="javascript:showAdjPage('${item[0].id}');"></c:if>调账<c:if test="${canAdj=='Y' && item[1].examined=='Y'}"></a></c:if>
							<a href="javascript:showRelBill('${item[0].id}','${item[0].billCode}');">单据跟踪</a>
						</td>
					</tr>
					</c:forEach>
		  		</table>  
      		</div>

      		<!-- 底栏 分页、操作等 -->
	        <div class="BottomToolBar ClearFix">
			    <%@include file="../inc/Pages.jsp"%>
	        </div>
			
		</div>
	</div>
</div>
</body>
</html>
<script type="text/javascript">
	function ChangeWindowSize( container, maxWidth ){
	    setTimeout( function(){
	        var w1 = document.documentElement.clientWidth-40;
	        if( w1>maxWidth ) w1 = maxWidth;
	        else if( w1<970 ) w1 = 960;
	        container.style.width = w1+'px';
	    }, 300 );
	}
	var IsAdvSearch = false;
	(function(){
		doInit();
		doPrintCallBack();
	    var ListContainer = document.getElementById('ListContainer');
	    ChangeWindowSize( ListContainer, 2020 );    // 超过 1280 的最大 1260 ，不全部铺满
	
	    var lnkMoreOption   = document.getElementById('lnkMoreOption');
	    var lnkHiddenOption = document.getElementById('lnkHiddenOption');
	    lnkMoreOption.onclick = function(){
	    	IsAdvSearch = true;
	        document.getElementById('dvMoreOptionBox').style.display = 'block';
	        document.getElementById('cb_cooper_date').style.visibility = 'visible';
	        this.style.visibility = 'hidden';
	    };
	    lnkHiddenOption.onclick = function(){
	    	IsAdvSearch = false;
	        document.getElementById('dvMoreOptionBox').style.display = 'none';
	        document.getElementById('cb_cooper_date').style.visibility = 'hidden';
	        lnkMoreOption.style.visibility = 'visible';
	    };
	})();
</script>
